<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head><title><spring:message code="member.list.title"/></title></head>
<body>
  <center><h2>회원목록</h2></center>
  <table width="550" align="center">
	    <tr>
	  	<td colspan="4" align="right">
	  	<c:if test="${!empty userId}">
	  	${userId}로그인 중 (<a href="logout.do">로그아웃</a>)
	  	</c:if>
	  	<c:if test="${empty userId}">
	  	<a href="login.do">로그인 하기</a>
	  	</c:if> 
	  	<a href="insert.do">등록</a>
	  	</td>
	  </tr>
  </table> 
 <c:if test="${count == 0}">
  <center> 출력할 리스트가 없습니다.</center>
 </c:if>
 <c:if test="${count > 0}">
	 <table width="550" border="1" align="center">
	  <tr>
	  	<td width="100">아이디</td>
	  	<td width="100">패스워드</td>
	  	<td width="100">이름</td>
	  	<td width="250">가입일자</td>
	  </tr>
	  <c:forEach var="member" items="${list}">
	  	<tr>
	  	   <td width="100"><a href="detail.do?id=${member.id }">${member.id } </a></td>
	  	   <td width="100">${member.passwd }</td>
	  	   <td width="100">${member.name }</td>
	  	   <td width="250"><fmt:formatDate value="${member.reg_date }" pattern="yyyy년 MM월 dd일"/></td>
	    </tr>
	  </c:forEach>
	</table>
	<div align="center">
	<c:if test="${count > 0}">
	   <c:set var="pageCount" value="${(count - 1) / pageSize + 1}"/>
	   <c:set var="pageBlock" value="${10}"/>
	   <fmt:parseNumber var="rs" value="${(currentPage - 1) / pageBlock}" integerOnly="true" />
	   <c:set var="startPage" value="${rs*pageBlock+1}"/>
	   <c:set var="endPage" value="${startPage + pageBlock-1}"/>
	   <c:if test="${endPage > pageCount}">
	        <c:set var="endPage" value="${pageCount}"/>
	   </c:if> 
	          
	   <c:if test="${startPage > pageBlock}">
	        <a href="list.do?pageNum=${startPage - pageBlock }">[이전]</a>
	   </c:if>
	
	   <c:forEach var="i" begin="${startPage}" end="${endPage}">
	       <c:if test="${i == currentPage}">
	          [${i}]
	       </c:if>
	       <c:if test="${i != currentPage}">
	           <a href="list.do?pageNum=${i}">[${i}]</a>
	       </c:if>
	   </c:forEach>
	
	   <c:if test="${endPage < pageCount}">
	        <a href="list.do?pageNum=${startPage + pageBlock}">[다음]</a>
	   </c:if>
	</c:if>
	</div>
</c:if>
</body>
</html>